<template>
	<view class="balanceList">
		<view class="top_box">
			<view class="top">
				<view class="top_left">
					<view class="left_name">
						目前账户余额 （元）
					</view>
					<view class="left_num">
						{{info.totalProceeds}}
					</view>
				</view>
				<view @click="towid" class="top_right">
					<view class="right_btn">
						提现
					</view>
				</view>
			</view>
			<view class="info_list">
				<view class="info_item">
					<!-- 	<view class="info_name">
						今日收益
					</view>
					<view class="info_num">
						{{info.todayProceeds}}
					</view> -->
				</view>
				<!-- <view class="info_item">
					<view class="info_name">
						本月收益
					</view>
					<view class="info_num">
						{{info.monthProceeds}}
					</view>
				</view> -->
				<view class="info_item">
					<!-- <view class="info_name">
						昨日收益
					</view>
					<view class="info_num">
						{{info.yesterdayProceeds}}
					</view> -->
				</view>

			</view>
		</view>
		<view class="big_title">
			收益明细
		</view>
		<uni-datetime-picker return-type="date" style="margin: 20upx 0;" :hide-second="true" v-model="datetimeranget"
			type="daterange" @change="change" rangeSeparator="至" />
		<view class="content_list">
			<view v-for="(item,index) in list" :key="index" class="item">
				<view class="left">
					<image src="../../static/tabsIcon/gold.png" mode=""></image>
					<view class="le_left">
						<view class="name">
							{{item.content}}
						</view>
						<view class="time">
							{{item.gmtCreate | times}}
						</view>
					</view>
				</view>
				<view @click="godetail(item.objectId,item.type)" class="right">
					{{item.isIncrease==1?'+':'-'}}{{item.balanceNum}}
					<view v-if="item.objectId" class="godetail">
						查看详情
					</view>
				</view>
			</view>
		</view>
		<u-loadmore @loadmore="getmore()" :load-text="loadText" :status="status" />
	</view>
</template>

<script>
	import {
		balanceuserrecord,
		balancerecordlist
	} from '@/api/mine'
	export default {
		data() {
			return {
				datetimeranget: [],
				info: [],
				list: [],
				page: 1,
				size: 10,
				total: 0,
				startTime: null,
				endTime: null,
				status: 'loadmore',
				loadText: {
					loadmore: '点击或上拉加载更多',
					loading: '努力加载中...',
					nomore: '没有更多了'
				},
			}
		},
		filters: {
			times(value) {
				let date = new Date(value);
				let y = date.getFullYear(); // 年
				let MM = date.getMonth() + 1; // 月
				MM = MM < 10 ? ('0' + MM) : MM;
				let d = date.getDate(); // 日
				d = d < 10 ? ('0' + d) : d;
				let h = date.getHours(); // 时
				h = h < 10 ? ('0' + h) : h;
				let m = date.getMinutes(); // 分
				m = m < 10 ? ('0' + m) : m;
				let s = date.getSeconds(); // 秒
				s = s < 10 ? ('0' + s) : s;
				// var timer =  y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s;
				var timer = y + '-' + MM + '-' + d;
				return timer;
			},
			man(value) {

			}
		},
		onReachBottom() {
			// console.log(123)
			if ((this.page * this.size) >= this.total) {
				this.status = 'nomore'
				return
			};
			// this.size = 20;
			this.status = 'loading';
			// this.page = this.page + 1;
			this.getmore();
		},
		onLoad() {
			this.getlist();
			this.getinfo();
		},
		methods: {
			change(e) {
				this.startTime = (e[0] || '')
				this.endTime = (e[1] || '')
				this.list = []
				this.page = 1
				this.size = 10
				this.total = 0
				this.getlist();
			},
			towid() {
				uni.navigateTo({
					url: './Withdrawal'
				})
			},
			godetail(id, type) {
				if (!id) {
					return
				}
				if (type == 21) {
					uni.navigateTo({
						url: `./orderdetail?type=0&id=${id}`,
					});
				} else if (type == 22) {
					uni.navigateTo({
						url: `./orderdetail?type=1&id=${id}`,
					});
				} else if (type == 23) {
					uni.navigateTo({
						url: `./orderdetail?type=2&id=${id}`,
					});
				} else if (type == 24) {
					uni.navigateTo({
						url: '../moive/orderdetails?id=' + id
					})
				} else if (type == 25) {
					uni.navigateTo({
						url: `./orderdetail?type=3&id=${id}`,
					});
				} else if (type == 26) {
					uni.navigateTo({
						url: '../moive/orderdetails?id=' + id
					})
				} else if (type == 28) {
					uni.navigateTo({
						url: `./orderdetail?type=5&id=${id}`,
					});
				}
			},
			getinfo() {
				balanceuserrecord().then(res => {
					// if (res.success == 1) {
					this.info = res.data
					// } else {
					// 	uni.showToast({
					// 		icon: 'none',
					// 		title: res.message
					// 	})
					// }
				})
			},
			getmore() {
				if ((this.page * this.size) >= this.total) {
					this.status = 'nomore'
					return
				};
				this.status = 'loading';
				this.page = this.page + 1;
				this.getlist();
			},
			getlist() {
				let data = {
					pageNum: this.page,
					pageSize: this.size,
					startTime: this.startTime,
					endTime: this.endTime
				}
				balancerecordlist(data).then(res => {
					if (res.success == 1) {
						if (this.page == 1) {
							this.list = res.data.records;
						} else {
							this.list.push(...res.data.records)
						}
						this.total = res.data.total;
						if ((this.page * this.size) >= this.total) {
							this.status = 'nomore'
						} else {
							this.status = 'loadmore'
						}
					} else {
						uni.showToast({
							icon: 'none',
							title: res.message
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	page {
		background: #f4f4f4;
	}

	.balanceList {
		// width: 100%;
		padding: 20rpx;
	}

	.top_box {
		background: url(../../static/tabsIcon/club/clubbg.png) no-repeat;
		color: #FFFFFF;
		background-size: 100% 100%;
		border-radius: 20rpx;
		padding: 40rpx;

		.top {
			display: flex;
			align-items: flex-start;
			justify-content: space-between;

			.top_left {
				.left_name {
					font-size: 28rpx;
					// margin-bottom: 20rpx;
				}

				.left_num {
					font-size: 60rpx;
				}
			}

			.top_right {
				width: 150rpx;
				height: 54rpx;
				text-align: center;
				line-height: 54rpx;
				font-size: 26rpx;
				border-radius: 30rpx;
				background: linear-gradient(90deg, #E33F33 0%, #EE6157 100%);
			}
		}

		.info_list {
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin-top: 66rpx;
			font-size: 28rpx;
			text-align: center;

			.info_name {
				margin-bottom: 10rpx;
			}
		}
	}

	.big_title {
		font-size: 30rpx;
		color: #131313;
		font-weight: bold;
		margin: 20rpx 0;
	}

	.content_list {
		width: 100%;

		.item {
			background: #FFFFFF;
			border-radius: 12rpx;
			padding: 20rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin: 20rpx 0;

			.left {
				width: 80%;
				display: flex;
				align-items: center;

				image {
					width: 90rpx;
					height: 90rpx;
					margin-right: 15rpx;
				}

				.le_left {
					width: 75%;
					// height: 90rpx;
					display: flex;
					flex-direction: column;
					justify-content: space-between;

					.name {
						color: rgba(0, 0, 0, 0.9);
						font-size: 30rpx;
						font-weight: 600;
						// width: 70%;
					}

					.time {
						color: rgba(195, 195, 195, 0.9);
						font-size: 22rpx;
					}
				}
			}

			.right {
				width: 20%;
				text-align: center;
				color: #333333;
				font-size: 34rpx;

				.godetail {
					font-size: 24rpx;
					margin-top: 10rpx;
				}
			}
		}
	}
</style>
